Skip to content

Resume after catch for interpreter via native EH#128728

Open
janvorli wants to merge 12 commits into
dotnet:mainfrom
janvorli:resume-after-catch-via-native-eh
Open

Resume after catch for interpreter via native EH#128728
janvorli wants to merge 12 commits into
dotnet:mainfrom
janvorli:resume-after-catch-via-native-eh

Conversation

@janvorli

Copy link
Copy Markdown
Member

This changes the way resume after catch in interpreted code works. It removes the need to use libunwind and uses C++ exception handling to unwind the stack.

This is basically the same way as we use for WASM, except for some extra handling of cases when the ResumeAfterCatchException would flow into managed frames. In those cases, we skip the managed frames using the explicit frames.

@janvorli janvorli self-assigned this May 28, 2026
Copilot AI review requested due to automatic review settings May 28, 2026 21:08
@janvorli janvorli requested review from BrzVlad and kg as code owners May 28, 2026 21:08
@janvorli

Copy link
Copy Markdown
Member Author

cc: @am11

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes CoreCLR interpreter resume-after-catch handling to use native C++ exception unwinding instead of the previous libunwind/manual unwind path, adding resume-after-catch handlers at native/managed boundaries and removing stored interpreter stack-pointer state.

Changes:

  • Adds ResumeAfterCatchException rethrow helpers and install/uninstall macros for native/managed boundary handling.
  • Updates interpreter, EH, QCall, PInvoke, prestub, VSD, and allocation helper paths to use the new propagation model.
  • Removes interpreter-frame saved SP plumbing and adjusts Unix UM entry prestub personalities.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/coreclr/vm/virtualcallstub.cpp Wraps VSD resolve workers with resume-after-catch handlers.
src/coreclr/vm/riscv64/asmhelpers.S Changes UM entry prestub personality to NoHandler.
src/coreclr/vm/qcall.h Adds resume-after-catch handling around QCalls.
src/coreclr/vm/prestub.cpp Adds handlers around prestub and interpreted-method execution.
src/coreclr/vm/loongarch64/asmhelpers.S Changes UM entry prestub personality to NoHandler.
src/coreclr/vm/jithelpers.cpp Wraps throw/rethrow helpers with context-based resume handling.
src/coreclr/vm/interpexec.h Removes obsolete saved-SP comment.
src/coreclr/vm/interpexec.cpp Removes saved-SP tracking and restores coop mode in resume-after-catch catch block.
src/coreclr/vm/i386/umthunkstub.S Changes UM entry prestub personality to NoHandler.
src/coreclr/vm/gchelpers.cpp Wraps failed allocation helper with resume-after-catch handling.
src/coreclr/vm/frames.h Removes interpreter-frame saved SP field/accessors.
src/coreclr/vm/frames.cpp Stops passing saved interpreter SP to floating-point register update.
src/coreclr/vm/exceptmacros.h Defines new resume-after-catch handler macros.
src/coreclr/vm/exceptionhandling.h Declares resume-after-catch rethrow helper.
src/coreclr/vm/exceptionhandling.cpp Implements managed-frame skipping rethrow helpers and wraps hardware EH path.
src/coreclr/vm/excep.cpp Generalizes native-frame propagation path and removes old resume-after-catch unwind helper.
src/coreclr/vm/eetwain.cpp Simplifies interpreter resume-after-catch to throw directly.
src/coreclr/vm/dllimport.cpp Wraps PInvoke import worker with resume-after-catch handling.
src/coreclr/vm/arm64/stubs.cpp Makes arm64 inlined-call-frame interpreter check null-safe.
src/coreclr/vm/arm64/asmhelpers.S Changes UM entry prestub personality to NoHandler.
src/coreclr/vm/amd64/umthunkstub.S Changes UM entry prestub personality to NoHandler.

Comment thread src/coreclr/vm/exceptionhandling.cpp Outdated
Comment thread src/coreclr/vm/amd64/umthunkstub.S
Comment thread src/coreclr/vm/exceptionhandling.cpp Outdated
@janvorli

Copy link
Copy Markdown
Member Author

The change was created / tested on macOS arm64. There seem to be some issues on other targets that I need to address.

janvorli added 2 commits May 29, 2026 08:34
This changes the way resume after catch in interpreted code works.
It removes the need to use libunwind and uses C++ exception handling
to unwind the stack.

This is basically the same way as we use for WASM, except for some
extra handling of cases when the ResumeAfterCatchException would
flow into managed frames. In those cases, we skip the managed frames
using the explicit frames.
Copilot AI review requested due to automatic review settings June 2, 2026 23:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/vm/interpexec.cpp
Comment thread src/coreclr/vm/exceptionhandling.cpp
Copilot AI review requested due to automatic review settings June 3, 2026 17:20
Comment thread src/coreclr/vm/exceptmacros.h Outdated
Comment thread src/coreclr/vm/interpexec.cpp
Copilot AI review requested due to automatic review settings June 4, 2026 12:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/vm/exceptmacros.h
Comment thread src/coreclr/vm/interpexec.cpp
Comment thread src/coreclr/vm/frames.cpp
@janvorli

janvorli commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread src/coreclr/vm/exceptmacros.h
@janvorli

janvorli commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread src/coreclr/vm/frames.cpp
Copilot AI review requested due to automatic review settings June 5, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/vm/interpexec.cpp
@janvorli

janvorli commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings June 8, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/vm/exceptmacros.h
Comment thread src/coreclr/vm/interpexec.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants